#include "LightSensor.h"

LightSensor::LightSensor(uint8_t pin) : pin(pin) {}

void LightSensor::begin() {
    pinMode(pin, INPUT);
    Serial.println("[Light] Sensor initialized");
}

bool LightSensor::getLightState() const {
    return positiveLogic == digitalRead(pin); // 确保返回bool
}

void LightSensor::controlLED(uint8_t ledPin) const {
    digitalWrite(ledPin, getLightState() ? HIGH : LOW);
}

void LightSensor::debugOutput() const {
    Serial.printf("[Light] Pin:%d State:%d Light:%s\n",
        pin, digitalRead(pin), 
        getLightState() ? "ON" : "OFF");
}
